<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=
    , initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script type="text/javascript">
        // //1.
        // var str1 = 'str';
        // str1 += 2;
        // var obj = typeof str1;  //obj = string
        // if (typeof obj == 'string') {
        //     var obj = new String()
        //     obj.sign = 'Live'
        // }
        // console.log(obj.sign);


//          2.
//   算出字符串的所占用字节的长度， 如: str  ='live' 长度为4     str='live生活'   长度为8 
//（提示:unicode<=255的占1字节，unicode>255的占用2字节, str.charCodeAt(i)查看i的字节码）
// var str ='live'
// console.log(str+'字节长度是'+str.length);
// var str ='live生活'
// var cons = 0
// for (let index = 0; index < str.length; index++) {
//     str.charCodeAt(index)>255 ? cons+=2 :cons++
// }
// console.log(cons);


// 3.要求输入一串低于10位的数字，输出对应的中文大写:
// 例： input: 10001  --> 一万零一     ；   input:  10,000,000  -->  一千万
var strNumber = ["零","一","二","三","四","五","六","七","八","九"]
var numberofweight = ['分','角','元','个','十','百','千','万']
var num = "1000000"
chinesesNumber(num);
function chinesesNumber (num) {
    var onum = num;
    if(onum==0){
        print(strNumber[num[0]]);
        return;
    }
    while(num != ''){
        if(num > 0){
            if(num[0] == 0){
                if(num.length<=4)
                    print(strNumber[num[0]]);
            }else{
                    print(strNumber[num[0]]);
                }
                if(num[0] > 0 || num.length>4)
                    print(numberofweight[num.length-1]); 
            }
                num = num.substring(1);
                while(num[0] ==0 && num[0]==1){
                    num = num.substring(1);
                }
            }
   
        }
 var chinses = chinesesNumber (num)
console.log(chinses); 


    </script>
</body>
</html>